package gameObject
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	
	public class Circle extends Bitmap
	{
		private var _radius:Number;
		private var _color:uint;
		
		public function Circle(Color:uint=0x00ff00,Radius:Number=15)
		{
			_color = Color;
			_radius = Radius;
			
			addEventListener(Event.ADDED_TO_STAGE,onAdded);
		}
		
		public function get color():uint
		{
			return _color;
		}

		public function set color(value:uint):void
		{
			_color = value;
			refresh();
		}

		public function get radius():Number
		{
			return _radius;
		}

		public function set radius(value:Number):void
		{
			_radius = value;
			refresh();
		}
		//////////////////////
		private function onAdded(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE,onAdded);
			
			refresh();
		}
		
		private function refresh():void
		{
			var sp:Sprite = new Sprite;
			
			sp.graphics.beginFill(_color);
			sp.graphics.drawCircle(_radius,_radius,_radius);
			sp.graphics.endFill();
			
			bitmapData = new BitmapData(_radius*2+1,_radius*2+1,true,0);
			bitmapData.draw(sp);
		}
		
		
		
	}
}